//
//  CTVAutoUpdate.h
//  Channltv
//
//  Created by Bruno Keymolen on 10/10/07.
//  Copyright 2007 channl.tv. All rights reserved.
//

#import <Cocoa/Cocoa.h>


@class CTVAutoUpdate, CTVAutoUpdateListener;

@protocol CTVAutoUpdateListener
	-(void)autoUpdateCheckDone:(NSString*)version;	
	-(void)autoUpdateCheckFail;		
@end


typedef enum CTVAUState{
	CTVAUIdle = 0,
	CTVAUCheck,
	CTVAUInstaller,
	CTVAUAppliance,
	CTVAUExecute,
	CTVAUDone
}CTVAUState;



@interface CTVAutoUpdate : NSObject {
	NSString* m_versionURLString;
	NSString* m_installerURLString;
	NSString* m_applianceURLString;
	NSMutableData* m_data;
	CTVAUState m_state;	
	BOOL m_updateAvailable;
	NSMutableArray* m_listeners;
	int m_versionMajor;
	int m_versionMinor;
	int m_versionRevision;
}


+(id)GetInstance;
-(void)setup;

-(BOOL)isProcessing;
-(void)checkNewVersion;
-(void)updateNow;
-(BOOL)updateAvailable;
-(void)resetUpdateAvailable;

-(void)addListener:(CTVAutoUpdateListener*)listener;
-(void)removeListener:(CTVAutoUpdateListener*)listener;

-(NSString*)latestVersion;

//Private
-(void)_informListenersFail;
-(void)_informListenersDone;
-(void)_applicanceDownload;

@end
